# from flask_restful import Resource
# from werkzeug.security import  generate_password_hash
# from restful.parser import RP_UserLogin
# from restful.response import ResponseNotFound,  ResponseSuccess, ResponseConflict, \
#     ResponseCreated
# from models import User, QueryOneInstance, UpdateInstance, Admin
#
# def create_user(cb=None):
#     args = RP_UserLogin()
#
#     user = QueryOneInstance(User, {'username': args['username']})
#
#     if user:
#         return ResponseConflict("已存在用户")
#
#     user = User(username=args['username'], password=generate_password_hash(args['password']))
#     user.put()
#
#     #用户admin表添加
#     if cb:
#         cb(user)
#
#     return ResponseCreated("创建用户成功")
#
# def delete_user(username):
#
#     args =
#
#     user = QueryOneInstance(User, {'username': args['username']})
#
#     if not user:
#         return ResponseNotFound("用户不存在")
#
#     user.delete()
#     return ResponseSuccess("删除用户成功")
#
# class CommonUserAccount(Resource):
#     def post(self):
#         return create_user()
#
#     def delete(self):
#         return delete_user()
#
# class AdminUserAccount(Resource):
#     def post(self):
#         def cb(user):
#             UpdateInstance(Admin,{'uid': user.id})
#         return create_user(cb)
#
#     def delete(self):
#         return delete_user()


